package cn.itsource.pet.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5;
import cn.itsource.basic.service.impl.BaseServiceImpl;
import cn.itsource.basic.util.AjaxResult;
import cn.itsource.basic.util.RedisService;
import cn.itsource.basic.util.SendMessageService;
import cn.itsource.basic.util.TreeUtil;
import cn.itsource.config.exception.BusinessException;
import cn.itsource.org.domain.User;
import cn.itsource.org.dto.LoginDto;
import cn.itsource.org.mapper.UserMapper;
import cn.itsource.org.query.UserQuery;
import cn.itsource.org.service.IUserService;
import cn.itsource.org.vo.LoginVo;
import cn.itsource.pet.mapper.PetTypeMapper;
import cn.itsource.pet.pojo.domain.PetType;
import cn.itsource.pet.query.PetTypeQuery;
import cn.itsource.pet.service.IPetTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Optional;

@Service
@Slf4j
//Propagation.SUPPORTS:支持别人事务
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class PetTypeServiceImpl extends BaseServiceImpl<PetType, PetTypeQuery> implements IPetTypeService {
    //基础查询由继承得到
    @Autowired
    private PetTypeMapper petTypeMapper;


    @Override
    public List<PetType> findPetTypeList() {
        //1.获取所有
        List<PetType> petTypeList = petTypeMapper.findPetTypeList();
        //2.工具类变成层级结构
        List<PetType> tree = TreeUtil.getTree(petTypeList);

        return tree;
    }



}
